const express = require('express');
const router = express.Router();
const adminController = require('../controllers/adminController');
const auth = require('../middlewares/auth');

// 登录路由 - 不需要认证
router.post('/login', adminController.login);

// 需要认证的路由
router.use(auth);

// 获取仪表盘数据
router.get('/dashboard', adminController.getDashboardData);

// 用户管理
router.get('/users', adminController.getUsers);
router.delete('/users/:id', adminController.deleteUser);

// 食谱管理
router.get('/recipes', adminController.getRecipes);
router.get('/recipes/:id', adminController.getRecipeById);
router.post('/recipes', adminController.createRecipe);
router.put('/recipes/:id', adminController.updateRecipe);
router.delete('/recipes/:id', adminController.deleteRecipe);

// 运动记录管理
router.get('/sport-records', adminController.getSportRecords);
router.delete('/sport-records/:id', adminController.deleteSportRecord);

// 饮食记录管理
router.get('/diet-records', adminController.getDietRecords);
router.delete('/diet-records/:id', adminController.deleteDietRecord);

// 食物管理路由
router.get('/foods', adminController.getFoods);
router.get('/foods/:id', adminController.getFoodById);
router.post('/foods', adminController.createFood);
router.put('/foods/:id', adminController.updateFood);
router.delete('/foods/:id', adminController.deleteFood);

// 帖子管理
router.get('/posts', adminController.getPosts);
router.delete('/posts/:id', adminController.deletePost);

module.exports = router; 